//
//  DiDiVPNHelper.m
//  KDExample
//
//  Created by YeQing on 2017/3/23.
//  Copyright © 2017年 naruto. All rights reserved.
//

#import "DiDiVPNHelper.h"
#import "DiDiVPNDefines.h"

@interface DiDiVPNHelper()

@end

@implementation DiDiVPNHelper

#pragma mark - 加载滴滴app的vpn manager
+ (void)loadDDVPNManager:(void(^)(NEVPNManager *vpnManager) )complate
{
    [NETunnelProviderManager loadAllFromPreferencesWithCompletionHandler:^(NSArray<NETunnelProviderManager *> * _Nullable managers, NSError * _Nullable error) {
        NEVPNManager *vpnManager = nil;
        //根据LocalizedDescription 查找 vpn manager
        if(managers.count > 0){
            for(int8_t i = 0; i < [managers count]; i++){
                if([[[managers objectAtIndex:i] localizedDescription] isEqualToString:kDiDiVPN_LocalizedDescription]){
                    vpnManager = [managers objectAtIndex:i];
                    break;
                }
            }
        }
        if(complate){
            complate(vpnManager);
        }
    }];
}

@end
